package com.example.mobile2021606128wje0427;

import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private RecyclerView rvMainTingchechang;
    private List<Tingchechang> list=new ArrayList<>();
    private int[] tingcehchang={R.drawable.tingchengchang_one, R.drawable.tingchechang_two,R.drawable.tingchechang_three, R.drawable.tingchechang_four, R.drawable.tingchechang_five};



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main );
        initView();
        initData();
        //线性布局
        rvMainTingchechang.setLayoutManager( new LinearLayoutManager( this ) );
        //设置适配器
        rvMainTingchechang.setAdapter( new TingchechangAdapter( list ) );

    }

    private void initView() {
        tvMainTitle = (TextView) findViewById( R.id.tv_main_title );
        rvMainTingchechang = (RecyclerView) findViewById( R.id.rv_main_tingchechang );
    }
    private void  initData(){
        list.add( new Tingchechang( R.drawable.tingchengchang_one,"广州南站","空位：20", "价格：15/小时","距离：20公里", "广州南站停车场A4区","更多信息" ) );
        list.add( new Tingchechang( R.drawable.tingchechang_two,"广州东站","空位：20", "价格：15/小时","距离：20公里", "广州东站停车场A4区","更多信息" ) );
        list.add( new Tingchechang( R.drawable.tingchechang_three,"虎门站","空位：20", "价格：15/小时","距离：20公里", "虎门站停车场A4区","更多信息" ) );
        list.add( new Tingchechang( R.drawable.tingchechang_four,"揭阳站","空位：20", "价格：15/小时","距离：20公里", "揭阳站停车场A4区","更多信息" ) );
        list.add( new Tingchechang( R.drawable.tingchechang_five,"深圳北站","空位：20", "价格：15/小时","距离：20公里", "深圳北站停车场A4区","更多信息" ) );

    }
}